<template>
	<!-- 工作台 -->
	<view class="page">
		<view class="head">
			<image class="work_bg" src="/pages/appraiser/static/work_bg.png" mode=""></image>
			<view class="head-info">
				<view :style="{'height':statusHeight+'px'}"></view>
				<view class="head_top">
					<view class="user">
						<image class="header-img" :src="vuex_imgUrl+userInfo.avatar" mode="" />
						<view class="text">
							<view class="text_1">{{userInfo.nickname}}</view>
							<view class="text2" v-if="userInfo.type == 1">球鞋鉴定师</view>
							<view class="text2" v-else-if="userInfo.type == 2">奢潮鉴定师</view>
						</view>
					</view>
					<view class="status" @click="change">
						接单中
						<u-switch v-model="userInfo.accepted" activeColor="#01FFCC" size="18"></u-switch>
					</view>
				</view>

				<view class="head-center">
					<view>
						<view class="text">累计鉴定次数</view>
						<view class="number">{{count.total}}</view>
					</view>
					<view>
						<view class="text">本月鉴定次数</view>
						<view class="number">{{count.mouth}}</view>
					</view>
					<view>
						<view class="text">本周鉴定次数</view>
						<view class="number">{{count.week}}</view>
					</view>
				</view>

				<view class="head-bottom" @click="goHome">
					<view class="head-bottom_l">
						<image class="switch_icon" src="/pages/appraiser/static/switch_icon.png" mode=""></image>
						<view>切换用户端</view>
					</view>
					<u-icon name="arrow-right" color="#FFFFFF" size="28rpx"></u-icon>
				</view>

			</view>
		</view>
		<view class="list">
			<view class="list_header">
				<view class="list_header_l">
					<image class="tbp_icon" src="/pages/appraiser/static/tbp_icon.png" mode="" />
					<view>待处理鉴定</view>
				</view>
				<view class="list_header_r" @click="$fn.jumpPage('/pages/appraiser/pages/allIdent')">
					<view>全部鉴定</view>
					<u-icon name="arrow-right" color="#999999" size="28rpx"></u-icon>
				</view>
			</view>
			<c-scroll-list ref="list" :option="{auto:false}" :api="api" :apiParams="{identified:0}" @load="load">
				<view class="list_item" v-for="(item,index) in orderList" :key="index"
					@click="$fn.jumpPage(`/pages/appraiser/pages/staffIdentDetails?param=${item.number}`)">
					<image class="logo" :src="vuex_imgUrl+ item.itemImage " mode=""></image>
					<view class="detail">
						<view class="serial">鉴定编号：{{item.number}}</view>
						<view class="date">{{$fn.parseTime(item.createTime)}}</view>
						<view class="status">待鉴定</view>
					</view>
				</view>
			</c-scroll-list>

		</view>
	</view>
</template>

<script>
	export default {
		name: "workTable",



		data() {
			return {
				api: this.$api.getAppraiserorderList,
				count: {},
				value: false,
				orderList: [],
				userInfo: {},
				statusHeight:0
			};
		},
		onLoad() {
			this.getUserInfo();
			this.getPhe()
		},
		onShow() {
			this.getIdentifiedCount();
			this.refresh()
			// this.getAppraiserorderList();
		},
		methods: {
			// 获取手机导航栏高度
			getPhe() {
				// 状态栏高度
				let systemInfo = uni.getSystemInfoSync()
				this.statusHeight = systemInfo.safeArea.top
			},

			refresh() {
				setTimeout(() => this.$refs.list.initList(), 500)
			},

			getIdentifiedCount() {
				this.$api.getIdentifiedCount().then(res => {
					console.log(res.data)
					this.count = res.data

				})
			},
			getAppraiserorderList() {
				this.$api.getAppraiserorderList({
					identified: 0
				}).then(res => {
					console.log(res.data, "鉴定师订单")
					this.orderList = res.data.list
				})
			},
			goHome() {
				uni.switchTab({
					url: '/pages/tabbar/home'
				})
			},
			getUserInfo() {
				let userInfo = uni.getStorageSync("userInfo");
				this.userInfo = userInfo;
				console.log(userInfo)
			},
			change() {
				this.$api.change().then(res => {
					console.log("切换")
					// this.userInfo.accepted = !this.userInfo.accepted

					this.$api.getUserInfo().then(res => {
						console.log(res, '用户信息')
						this.userInfo = res.data
					})

					uni.setStorageSync("userInfo", this.userInfo)
					// this.userInfo =  uni.getStorageSync("userInfo")
					console.log(this.userInfo.accepted)
				})
			},
			// 获取数据列表
			load(res) {
				console.log(res, '列表数据');
				this.orderList = res.list
			}
		}
	};
</script>

<style lang="scss" scoped>
	.head {
		width: 750rpx;
		height: 600rpx;
		background: linear-gradient(180deg, #000000 0%, #4D4D4D 100%);
		position: relative;

		.work_bg {
			width: 640rpx;
			height: 400rpx;
			position: absolute;
			right: 0;
			bottom: 0;
		}

		.head-info {
			width: 750rpx;
			height: 500rpx;
			position: absolute;
			left: 0;
			top: 0;
			padding: 60rpx 32rpx 0;
			box-sizing: border-box;


			.head_top {
				display: flex;
				align-items: center;
				justify-content: space-between;
			}

			.user {
				display: flex;
				align-items: center;
				gap: 32rpx;

				.header-img {
					width: 120rpx;
					height: 120rpx;
					border-radius: 8rpx;
				}

				.text {
					height: 120rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.text_1 {
						font-weight: bold;
						font-size: 40rpx;
						color: #FFFFFF;
					}

					.text2 {
						font-size: 28rpx;
						color: #01FFCC;
					}

				}

			}

			.status {
				display: flex;
				align-items: center;
				gap: 10rpx;
				font-size: 28rpx;
				color: #FFFFFF;
			}

			.head-center {
				display: flex;
				align-items: center;
				justify-content: space-between;
				margin-top: 48rpx;

				.text {
					font-weight: 400;
					font-size: 24rpx;
					color: #FFFFFF;
				}

				.number {
					font-weight: 800;
					font-size: 40rpx;
					color: #FFFFFF;
					margin-top: 12rpx;
				}
			}

			.head-bottom {
				background: #4D4D4D;
				border-radius: 12rpx;
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 20rpx;
				box-sizing: border-box;
				margin-top: 32rpx;

				.head-bottom_l {
					display: flex;
					align-items: center;
					gap: 16rpx;
					font-size: 28rpx;
					color: #FFFFFF;


					.switch_icon {
						width: 28rpx;
						height: 28rpx;
					}
				}

			}
		}
	}

	.list {
		padding: 32rpx;
		box-sizing: border-box;
		border-radius: 24rpx 24rpx 0rpx 0rpx;
		margin-top: -40rpx;
		background-color: #FFFFFF;
		position: relative;
		z-index: 3;

		.list_header {
			display: flex;
			align-items: center;
			justify-content: space-between;

			.list_header_l {
				display: flex;
				align-items: center;
				gap: 10rpx;
				font-weight: bold;
				font-size: 32rpx;
				color: #1A1A1A;

				.tbp_icon {
					width: 26rpx;
					height: 32rpx;
				}
			}

			.list_header_r {
				display: flex;
				align-items: flex-end;
				font-weight: 400;
				gap: 4rpx;
				font-size: 24rpx;
				color: #999999;
			}

		}

		.list_item {
			padding: 28rpx 0;
			display: flex;
			align-items: center;
			gap: 28rpx;
			border-bottom: 1rpx solid #E6E6E6;

			.logo {
				width: 128rpx;
				height: 128rpx;
				border-radius: 8rpx;
			}

			.detail {
				height: 128rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;

				.serial {
					font-weight: bold;
					font-size: 28rpx;
					color: #1A1A1A;
				}

				.date {
					font-weight: 400;
					font-size: 24rpx;
					color: #666666;
				}

				.status {
					font-size: 24rpx;
					color: #FF9500;
				}
			}

		}
	}
</style>